package cn.jluzh.blog.mapper;

import cn.jluzh.blog.modules.log.eneity.SysLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author hzhii
 */
@Repository
public interface SysLogMapper extends BaseMapper<SysLog> {

    /**
     * 根据用户id获取记录信息
     * @param id 记录id
     * @return 记录信息
     */
    @Select("select * from sys_log where user_id = #{id}")
    SysLog selectByUserId(Integer id);

    /**
     * 查询用户所有的日志记录
     * @param userName 用户名
     * @return syslog
     * */
    @Select("select request_ip,time,address,browser from sys_log where username = #{userName} order by time desc")
    List<SysLog> getUserLog(@Param("userName")String userName);


}
